home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
batch
/
powerbat
/
calc.pwr
< prev
next >
Wrap
Text File
|
1994-05-17
|
12KB
|
352 lines
Variable Work,255
Variable Month,2
Variable Day,2
Variable Year,4
Variable Time,11
Variable CurClr,3
Variable Normal,1,1
Variable On,1,1
Variable Off,1,0
Variable Zeros,18,'000000000000000000'
Variable Spaces,18,' '
Variable Cmds1,100,'224Number Of Decimals 2332 224Memory Cell 233Esc224 Exit'
Variable Cmds2,100,'233+224 Add 233-224 Subtract 233*224 Multiply 233/224 Divide 233F1224 Decimals'
Variable Cmds3,100,'233F2224 Clr Total 233F3224 Clr Memory 233F4224 Recall Memory'
Variable Cmds4,100,'233F5224 Add to Mem 233F6224 Sub fr Mem 233F7224 Stor to Mem '
Variable Plus,1,#43
Variable Minus,1,#45
Variable Mult,1,#42
Variable Div,1,#47
Variable F1,1,#59
Variable F2,1,#60
Variable F3,1,#61
Variable F4,1,#62
Variable F5,1,#63
Variable F6,1,#64
Variable F7,1,#65
Variable Esc,1,#27
Variable Mem1,18,0
Variable Mem2,18,0
Variable Mem3,18,0
Variable Mem4,18,0
Variable Total,18,0
Variable Entry,18,0
Variable RtnCode,2
Variable NumDecs,2,2
Variable CtrLgth,2
Variable DecLoc,2
Variable DecToAdd,2
Variable Func,1,' '
Variable Spec,1
?Color Work,Work,CurClr
Cursor Off
EnhanClr On
Clear 135,,'░'
Box1 1,1,57,3,228 ;Title box
Box1 1,20,57,25,228 ;msg box at bottom
Box1 58,1,80,25,240 ;"tape" box
Box1 3,5,27,7,158 ;mem 1 box
Box1 31,5,55,7,158 ;mem 2 box
Box1 3,10,27,12,158 ;mem 3 box
Box1 31,10,55,12,158 ;mem 4 box
Box1 18,15,40,17,160 ;entry box
WriteAt 17,2,'The PowerBatch Calculator',228
?Date Work,Month,Day,Year
Concat Work,Month,'/',Day,'/',Year
WriteAt 3,3,Work,228
WriteAt 11,5,'Memory 1',159
WriteAt 39,5,'Memory 2',159
WriteAt 11,10,'Memory 3',159
WriteAt 39,10,'Memory 4',159
WriteAt 27,15,'Entry',160
WriteAt 3,21,Cmds1
WriteAt 3,22,Cmds2
WriteAt 3,23,Cmds3
WriteAt 3,24,Cmds4
GoTo DispMem
Label NextCalc
SetVar DecToAdd,NumDecs
LocStr '.',Entry,1,DecLoc ;force a decimal
Compare DecLoc,0,Dec1
Concat Entry,'.'
LocStr '.',Entry,1,DecLoc
Label Dec1
Length CtrLgth,Entry ;align the decimal
Subtract CtrLgth,DecLoc
Subtract DecToAdd,CtrLgth
SetVar Work,''
MidString Work,Zeros,1,DecToAdd ;get some zeros
Concat Entry,Work ;add to units pos
Length CtrLgth,Entry ;left space fill
SetVar DecToAdd,19
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Entry,Func ;add to high order
Window1 58,1,80,25,240 ;open our tape window
GoToXy 1,23 ; so we scroll
WriteLine Work,240
Label PrtTotal
SetVar DecToAdd,NumDecs
LocStr '.',Total,1,DecLoc ;force a decimal
Compare DecLoc,0,TotDec
Concat Total,'.'
LocStr '.',Total,1,DecLoc
Label TotDec
Length CtrLgth,Total ;align the decimal
Subtract CtrLgth,DecLoc
Subtract DecToAdd,CtrLgth
SetVar Work,''
MidString Work,Zeros,1,DecToAdd ;get some zeros
Concat Total,Work ;add to units pos
Length CtrLgth,Total ;left space fill
SetVar DecToAdd,19
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Total,'=' ;add to high order
Window1 58,1,80,25,240 ;open our tape window
GoToXy 1,23 ; so we scroll
WriteLine Work,240
Window0 1,1,80,25 ;full screen
Label DispMem
Length CtrLgth,Mem1 ;left space fill
SetVar DecToAdd,20
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Mem1,' ' ;add to high order
WriteAt 4,6,Work,154
Length CtrLgth,Mem2 ;left space fill
SetVar DecToAdd,20
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Mem2,' ' ;add to high order
WriteAt 32,6,Work,154
Length CtrLgth,Mem3 ;left space fill
SetVar DecToAdd,20
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Mem3,' ' ;add to high order
WriteAt 4,11,Work,154
Length CtrLgth,Mem4 ;left space fill
SetVar DecToAdd,20
Subtract DecToAdd,CtrLgth
MidString Work,Spaces,1,DecToAdd ;get some spaces
Concat Work,Work,Mem4,' ' ;add to high order
WriteAt 32,11,Work,154
Label GetFunc
ClearBox 18,15,40,17,160
Label ShowTime
?Time Time ;get curr time
Cursor Off
WriteAt 45,3,Time,228 ;disp time
GoToXY 19,16
Cursor Normal
Color 160
ReadKey Func,Spec,1 ;get our math function
Compare Func,'',,,ShowTime ;did we time out
Compare Spec,'0',FuncKey ;was the key a special key
Compare Func,Esc,,,EndPgm ;end the pgm
Compare Func,Plus,,,CalcAdd ;check the functions
Compare Func,Minus,,,CalcMinus
Compare Func,Mult,,,CalcMult
Compare Func,Div,,,CalcDiv
Cursor Off ;if we get here, invalid key
GoTo GetFunc
Label FuncKey ;special key was entered
Compare Func,F1,,,SetDecimals
Compare Func,F2,,,ClearTot
Compare Func,F3,,,ClearMem
Compare Func,F4,,,RecallMem
Compare Func,F5,,,AddMem
Compare Func,F6,,,SubMem
Compare Func,F7,,,StoreMem
GoTo GetFunc
Label CalcAdd
ReadStr Entry
Add Total,Entry,RtnCode,NumDecs ;add to the total
Compare RtnCode,0,,NextCalc,NextCalc
GoTo MathErr
Label CalcMinus
ReadStr Entry
Subtract Total,Entry,RtnCode,NumDecs ;sub from the total
Compare RtnCode,0,,NextCalc,NextCalc
GoTo MathErr
Label CalcMult
ReadStr Entry
Multiply Total,Entry,RtnCode,NumDecs ;multiply total by entry
Compare RtnCode,0,,NextCalc,NextCalc
GoTo MathErr
Label CalcDiv
ReadStr Entry
Divide Total,Entry,RtnCode,NumDecs ;divide total by entry
Compare RtnCode,0,,NextCalc,NextCalc
GoTo MathErr
Label SetDecimals
Cursor Normal
Color 224
GoToXY 22,21 ;find out how many decimals
Color 228
ReadStr NumDecs
Cursor Off
GoTo GetFunc
Label ClearTot
SetVar Total,0
GoTo PrtTotal
Label ClearMem
SetVar Mem1,0
SetVar Mem2,0
SetVar Mem3,0
SetVar Mem4,0
GoTo DispMem
Label RecallMem
GoToXy 38,21
Color 228
ReadKey Func ;which memory counter
Compare Func,1,TryMRec2,GetFunc
SetVar Total,0
SetVar Entry,0
SetVar Func,'R' ;so it shows as recall
SetVar Entry,Mem1
Add Total,Entry,RtnCode,NumDecs
Compare RtnCode,0,,,NextCalc
GoTo MathErr
Label TryMRec2
Compare Func,2,TryMRec3
SetVar Total,0
SetVar Entry,0
SetVar Func,'R'
SetVar Entry,Mem2
Add Total,Entry,RtnCode,NumDecs
Compare RtnCode,0,,,NextCalc
GoTo MathErr
Label TryMRec3
Compare Func,3,TryMRec4
SetVar Total,0
SetVar Entry,0
SetVar Func,'R'
SetVar Entry,Mem3
Add Total,Entry,RtnCode,NumDecs
Compare RtnCode,0,,,NextCalc
GoTo MathErr
Label TryMRec4
Compare Func,4,GetFunc
SetVar Total,0
SetVar Entry,0
SetVar Func,'R'
SetVar Entry,Mem4
Add Total,Entry,RtnCode,NumDecs
Compare RtnCode,0,,,NextCalc
GoTo MathErr
Label AddMem
GoToXy 38,21
Color 228
ReadKey Func ;which memory counter
Compare Func,1,TryMAdd2,GetFunc
Add Mem1,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMAdd2
Compare Func,2,TryMAdd3
Add Mem2,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMAdd3
Compare Func,3,TryMAdd4
Add Mem3,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMAdd4
Compare Func,4,GetFunc
Add Mem4,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label SubMem
GoToXy 38,21
Color 228
ReadKey Func ;which memory counter
Compare Func,1,TryMSub2,GetFunc
Subtract Mem1,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMSub2
Compare Func,2,TryMSub3
Subtract Mem2,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMSub3
Compare Func,3,TryMSub4
Subtract Mem3,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMSub4
Compare Func,4,GetFunc
Subtract Mem4,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
label StoreMem
GoToXy 38,21
Color 228
ReadKey Func ;which memory counter
Compare Func,1,TryMStr2,GetFunc
SetVar Mem1,0
Add Mem1,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMStr2
Compare Func,2,TryMStr3
SetVar Mem2,0
Add Mem2,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMStr3
Compare Func,3,TryMStr4
SetVar Mem3,0
Add Mem3,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label TryMStr4
Compare Func,4,GetFunc
SetVar Mem4,0
Add Mem4,Total,RtnCode,NumDecs
Compare RtnCode,0,,,DispMem
GoTo MathErr
Label MathErr
Cursor Off
Box1 2,21,55,23,48
WriteAt 22,21,' MATH ERROR ',62
WriteAt 3,22,'Totals May be Damaged. Restart May Be Necessary.',52
WriteAt 22,23,'Press Any Key',62
ReadKey Func
ClearBox 1,20,57,25,228 ;msg box at bottom
WriteAt 3,21,Cmds1 ;restore the box
WriteAt 3,22,Cmds2
WriteAt 3,23,Cmds3
WriteAt 3,24,Cmds4
SetVar Entry,0
GoTo NextCalc
Label EndPgm
EnhanClr Off
Cursor On
Color CurClr ;restore the orig color
Clear CurClr